<?php require_once('../../Connections/cotiza.php'); ?>
<?php
$campo = $_GET['campo'];
$acc   = $_GET['acc'];
$label = $_GET['label'];

mysql_select_db($database_cotiza, $cotiza);

if($acc == "search")
{
	$b = $_POST['busqueda'];
	$query = "SELECT mach_id, mach_desc, proc_desc FROM mach_mstr, proc_mstr WHERE mach_proc = proc_id AND (mach_id like '%$b%' OR mach_desc like '%$b%' OR proc_desc like '%b%') ORDER BY mach_id";
	echo $query;
}
else
	$query = "SELECT mach_id, mach_desc, proc_desc FROM mach_mstr, proc_mstr WHERE mach_proc = proc_id ORDER BY mach_id";
	
$busqueda = mysql_query($query, $cotiza) or die(mysql_error());
$row = mysql_fetch_assoc($busqueda);
$totalRows = mysql_num_rows($busqueda);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>..:: Maquinas ::..</title>
<link href="../../main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.default_title {
	color: #FFF;
}
-->
</style>
</head>

<body onload="document.form1.busqueda.focus();">
<form id="form1" name="form1" method="post" action="maquinas.php?campo=<?php echo $campo; ?>&acc=search">
  <table border="0" align="center">
    <tr>
      <td >B&uacute;squeda de Maquina:</td>
      <td ><input name="busqueda" class="default" size="20" autocomplete="off" value="<?php echo $b;?>"/></td>
      <td ><input type="submit" value="Buscar" class="v8" /></td>
    </tr>
  </table>
</form>
<br />
<?php if($totalRows >0){?>
  <table border="1" align="center" cellpadding="2" cellspacing="0">
    <tr class="default_title">
      <td width="80" align="center" bgcolor="#0000CC">Id Maquina</td>
      <td width="180" align="center" bgcolor="#0000CC">Descripci&oacute;n</td>
      <td width="90" align="center" bgcolor="#0000CC">Proceso</td>
    </tr>
    <?php do { ?>
    <tr>
      <td><a href="javascript:window.opener.document.getElementById('<?php echo $campo; ?>').value= '<?php echo $row['mach_id']; ?>';<?php if($label <> "") echo "window.opener.document.getElementById('$label').innerHTML = '".$row['mach_desc']."';"; ?>window.opener.document.getElementById('<?php echo $campo; ?>').focus();window.close();"> <?php echo $row['mach_id']; ?> </a>&nbsp;</td>
      <td> <?php echo $row['mach_desc']; ?>&nbsp;</td>
      <td><?php echo $row['proc_desc']; ?></td>
    </tr>
      <?php } while ($row = mysql_fetch_assoc($busqueda)); ?>
  </table>
<?php }?>
</body>
</html>
<?php 
mysql_close($cotiza);
?>